Понедельник — отличный день, чтобы разогреть мозги небольшим техническим кейсом 💡 Сегодня короткий, но полезный пост — с ответом сразу.
📌 Дано:
create table demo_table ( ID char(4 CHAR), value VARCHAR2(64 CHAR) );
Известно, что есть следующие индексы и ключи:
create index DEMO_TBL_VALUE_IX on demo_table (VALUE);
alter table DEMO_TABLE add constraint DEMO_TBL_PK primary key (ID) using index;
Вопрос (c подвохом) почему такая вставка проходит:
insert into demo_table values('0001', 1000);
А эта падает с ошибкойORA-01722: неверное число:
insert into demo_table values('0002', 'Test');
Ответ при наличии следующего индекса
create index DEMO_TBL_NUM_IX on demo_table(trunc(VALUE));
Такая конструкция называется индексом по функции (function based index). В реальных проектах она используется довольно часто, например, когда на строковое поле мы создаем индекс UPPER(<column>). Особенность такого индекса в том, что в листьях он хранит результат выполнения этой функции для каждого rowid. Поэтому никакой магии тут нет: если мы не можем записать в индекс результат функции, то и вставку выполнить мы не можем.
В нашем случае, функция trunc пытается примениться к значению value. В первой строке - 1000 (все ок), во второй - 'Test' (ошибка).
Ставьте лайк, если было познавательно. 🔔 Если хотите узнать больше про индексы, следите за каналом — завтра будет важное объявление.
Понедельник — отличный день, чтобы разогреть мозги небольшим техническим кейсом 💡 Сегодня короткий, но полезный пост — с ответом сразу.
📌 Дано:
create table demo_table ( ID char(4 CHAR), value VARCHAR2(64 CHAR) );
Известно, что есть следующие индексы и ключи:
create index DEMO_TBL_VALUE_IX on demo_table (VALUE);
alter table DEMO_TABLE add constraint DEMO_TBL_PK primary key (ID) using index;
Вопрос (c подвохом) почему такая вставка проходит:
insert into demo_table values('0001', 1000);
А эта падает с ошибкойORA-01722: неверное число:
insert into demo_table values('0002', 'Test');
Ответ при наличии следующего индекса
create index DEMO_TBL_NUM_IX on demo_table(trunc(VALUE));
Такая конструкция называется индексом по функции (function based index). В реальных проектах она используется довольно часто, например, когда на строковое поле мы создаем индекс UPPER(<column>). Особенность такого индекса в том, что в листьях он хранит результат выполнения этой функции для каждого rowid. Поэтому никакой магии тут нет: если мы не можем записать в индекс результат функции, то и вставку выполнить мы не можем.
В нашем случае, функция trunc пытается примениться к значению value. В первой строке - 1000 (все ок), во второй - 'Test' (ошибка).
Ставьте лайк, если было познавательно. 🔔 Если хотите узнать больше про индексы, следите за каналом — завтра будет важное объявление.
To pay the bills, Mr. Durov is issuing investors $1 billion to $1.5 billion of company debt, with the promise of discounted equity if the company eventually goes public, the people briefed on the plans said. He has also announced plans to start selling ads in public Telegram channels as soon as later this year, as well as offering other premium services for businesses and users.
Telegram and Signal Havens for Right-Wing Extremists
Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.